﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Peak.Core;
using Peak.Resources;

namespace Peak.Web
{
  public static class Enums
  {    
    public static IEnumerable<SelectListItem> GetSprintStatusValues(SprintStatus currentStatus)
    {
      List<SelectListItem> list = new List<SelectListItem>();
      list.Add(new SelectListItem() { Selected = currentStatus == SprintStatus.Planning, Text = Statuses.Planning, Value = "Planning" });
      list.Add(new SelectListItem() { Selected = currentStatus == SprintStatus.InProgress, Text = Statuses.InProgress, Value = "InProgress" });
      list.Add(new SelectListItem() { Selected = currentStatus == SprintStatus.Finished, Text = Statuses.Finished, Value = "Finished" });      
      return list;
    }

    public static IEnumerable<SelectListItem> GetTaskStatusValues(TaskStatus currentStatus, string category)
    {
      List<SelectListItem> list = new List<SelectListItem>();
      list.Add(new SelectListItem() { Selected = currentStatus == TaskStatus.ToDo, Text = Statuses.ToDo, Value = "ToDo" });
      list.Add(new SelectListItem() { Selected = currentStatus == TaskStatus.InProgress, Text = Statuses.InProgress, Value = "InProgress" });
      if(category != null && category.ToLower().Contains("bug"))
      {
        list.Add(new SelectListItem() { Selected = currentStatus == TaskStatus.ReadyForTest, Text = Statuses.ReadyForTest, Value = "ReadyForTest" });
      }
      list.Add(new SelectListItem() { Selected = currentStatus == TaskStatus.Done, Text = Statuses.Done, Value = "Done" });
      return list;
    }   

    public static IEnumerable<SelectListItem> GetStoryStatusValues(StoryStatus status)
    {
      List<SelectListItem> list = new List<SelectListItem>();
      list.Add(new SelectListItem() { Selected = status == StoryStatus.ToDo, Text = "ToDo", Value = "ToDo" });
      list.Add(new SelectListItem() { Selected = status == StoryStatus.InProgress, Text = "InProgress", Value = "InProgress" });
      list.Add(new SelectListItem() { Selected = status == StoryStatus.Verify, Text = "Verify", Value = "Verify" });
      list.Add(new SelectListItem() { Selected = status == StoryStatus.Done, Text = "Done", Value = "Done" });
      return list;
    }

    public static IEnumerable<SelectListItem> GetStoryPointsValues(int storyPoints)
    {
      List<SelectListItem> list = new List<SelectListItem>();
      list.Add(new SelectListItem() { Selected = storyPoints == 0, Text = "0", Value = "0" });
      list.Add(new SelectListItem() { Selected = storyPoints == 0.5, Text = "0.5", Value = "0.5" });
      list.Add(new SelectListItem() { Selected = storyPoints == 1, Text = "1", Value = "1" });
      list.Add(new SelectListItem() { Selected = storyPoints == 2, Text = "2", Value = "2" });
      list.Add(new SelectListItem() { Selected = storyPoints == 3, Text = "3", Value = "3" });
      list.Add(new SelectListItem() { Selected = storyPoints == 5, Text = "5", Value = "5" });
      list.Add(new SelectListItem() { Selected = storyPoints == 8, Text = "8", Value = "8" });
      list.Add(new SelectListItem() { Selected = storyPoints == 13, Text = "13", Value = "13" });
      list.Add(new SelectListItem() { Selected = storyPoints == 20, Text = "20", Value = "20" });
      list.Add(new SelectListItem() { Selected = storyPoints == 40, Text = "40", Value = "40" });
      list.Add(new SelectListItem() { Selected = storyPoints == 100, Text = "100", Value = "100" });
      return list;
    }        
  }
}
